<template>
	<view>
		<!-- <button @click="sendPost()">POST请求</button> -->
		<view class="titleStyle">
			<button class="buttonTitle default" hover-class="none">正常</button>
			<button class="buttonTitle warn" hover-class="none">离线</button>
		</view>
		
				  <buttonDL :buttonList="activeArr" @itemClick="goDetail"></buttonDL>
				  
	</view>
</template>

<script>
	import buttonDL from '../../components/button-device-list/button-device-list.vue'

	export default {
		data() {
			return {
				activeArr: [],
				flag: true,
				e:true,
				f:true,
			
			}
		},
		methods: {
			async sendPost(){
				
				const res = await this.$myRequest({
					url: '/makerwit/wms/queryAGVDeviceState',
					data: '{}',
					method: 'POST'
				})
				console.log('=============================',res)
				console.log("----------",res.data.data[0].name)
				console.log("----------",res.data.data[0].name.slice(0,1) == 'A')
				for(let i = 0; i < res.data.data.length;i++){
					if(res.data.data[i].name.slice(0,1) == 'B'){
						this.activeArr = [...this.activeArr, res.data.data[i]]
					}
				}
				//this.activeArr = res.data.data
				
			},
			//跳转
			pathccc(res){
				console.log("点击Button按钮：",res)
				uni.navigateTo({
				    url: '../deviceInfo/deviceInfo?res='+res.id
				});

			},
			goDetail (id) {
				uni.navigateTo({
					url: '/pages/devicestatusInfo/devicestatusInfo?id='+id
				})
			}
			
		},
	
		onLoad(options){
			console.log('页面加载了',options)
			this.sendPost()
			
		},
		
		components:{
			"buttonDL": buttonDL
		}
	}
</script>

<style>
.cu{
	width: 40%;
	height: 120rpx;


	 margin-top: 15px; 
	 margin-left:6%;
	 float:left;


display: flex;
    justify-content: center;
    align-items: center;


}
.titleStyle{
			padding: 0 15rpx;
			display: flex;
			flex-wrap: wrap;
			justify-content: space-between;
}
.buttonTitle{
	width: 255rpx;
	margin: 10rpx 40rpx 10rpx 40rpx;
	padding: 15rpx;
	box-sizing: border-box;
}
.default{
				background-color: #5677fc;
				color: #FFFFFF;
}
			.warn{
				
				background-color: #ff7900;
				color: #FFFFFF;
			}
</style>
